﻿@model IEnumerable<CREAPA.Dominio.OS>

@{
    ViewBag.Title = "ListaPendentes" + " "+"("+@ViewBag.TotalOS+")";
}
<script src="~/Scripts/AlertaPersonalizado.js"></script>
<link rel="stylesheet" href="@Url.Content("~/Content/style.css")" />

<h2>OS Pendentes de Análise (@ViewBag.TotalOS)</h2>

<script>setTimeout("window.location.reload();", 600000);</script>

@{
    if (TempData["ExcluirOS"] != null) {
        TempData["ExcluirOS"]=null;
 <body onload="Alert.render('OS Excluida Com Sucesso')">
 <div id="dialogoverlay"></div>
 <div id="dialogbox"><div>
 <div id="dialogboxhead"></div>
 <div id="dialogboxbody"></div>
 <div id="dialogboxfoot"></div>
 </div>
 </div>
 </body>
    }
 }

@{
    if (TempData["AnaliseOS"] != null) {
        TempData["AnaliseOS"]=null;
 <body onload="Alert.render('OS Analisada Com Sucesso')">
 <div id="dialogoverlay"></div>
 <div id="dialogbox"><div>
 <div id="dialogboxhead"></div>
 <div id="dialogboxbody"></div>
 <div id="dialogboxfoot"></div>
 </div>
 </div>
 </body>
    }
 }

<p>
    @Html.ActionLink("Ver Todas", "ListaTodasSetor", null, new { @class = "link-button" })
    @Html.ActionLink("Visualizar Tela Cheia", "ListaPendentes2", null, new { @class = "link-button" })
    @Html.ActionLink("Relatórios de Análise por Funcionário", "RelatorioAnalise", null, new { @class = "link-button" })
    @Html.ActionLink("Relatórios de Problemas Cadastrados", "RelatorioProblema", null, new { @class = "link-button" })
</p>
<br />

@{
    WebGrid grid = new WebGrid(source: Model, columnNames: new string[] { "Id", "Descricao", "DataCadOs", "PessoaCadastrou", "PessoaInteressado", "Problema", "Setor", "OrigemOS" }, canPage: true, rowsPerPage: 50);
}
<div id="content">
@grid.GetHtml( tableStyle: "table",
        alternatingRowStyle: "alternate",
        headerStyle: "header",
        footerStyle: "footer",
        mode: WebGridPagerModes.FirstLast | WebGridPagerModes.NextPrevious,
        firstText: "Primeiro",
        previousText: "Anterior",
        nextText: "Próximo",
        lastText: "Último",columns: grid.Columns(
              grid.Column("Id", header:"Número", format: @<text><center>@item.Id</center></text>),
              grid.Column("Problema", header:"Problema", format: @<text>@item.Problema</text>),              
              grid.Column("Descricao", header:"Descrição", format: @<text><div style='width: 40em'>@item.Descricao</div></text>),
              grid.Column("DataCadOs", header:"Data de Cadastro", format: @<text>@item.DataCadOs</text>),
              grid.Column("PessoaInteressado", header:"Interessado", format: @<text>@item.PessoaInteressado</text>),
             
              grid.Column("Setor", header:"Setor", format: @<text>@item.Setor</text>),
              grid.Column("Prioridade", header:"Prioridade", format: @<text>@item.Prioridade</text>),

            grid.Column("Analisar",   header: "Analisar",   format: @<text><center>@Html.ActionLink("Analisar", "Analisar", new { id = item.Id })</center></text>),
            grid.Column("Excluir",   header: "Excluir",   format: @<text><center>@Html.ActionLink("Excluir", "Excluir", new { id = item.Id })</center></text>)
	          
           )
)
</div>
<script src="~/Scripts/TabelBackgroundColor.js"></script>
<script>
    $(document).ready(function () {
        $("#content tbody tr").each(function (i, Column) {
            var priceYesterday = $(this).find("td:nth-child(7)").html();
            var priceToday = $(this).find("td:nth-child(7)").html();

            //check if its greater than zero
            if (priceToday == 'Alta') {
                //change the color of the text to green if its a positive number
                $(this).find("td:nth-child(1)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(2)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(3)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(4)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(5)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(6)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(7)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(8)").css("background-color", "#EE2C2C");
                $(this).find("td:nth-child(9)").css("background-color", "#EE2C2C");
            }
            //else if (priceToday == 'Média') {
            //    //change the color of the text to red if its a negatice number
            //    $(this).find("td:nth-child(1)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(2)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(3)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(4)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(5)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(6)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(7)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(8)").css("background-color", "#EEEE00");
            //    $(this).find("td:nth-child(9)").css("background-color", "#EEEE00");
            //}
        });
    });
</script>

